<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html {
      height: 5000px;
    }

    .fixed {
      position: fixed;
      right: 5px;
      top: 5px;
    }
  </style>
  <!-- <script>
        // 等页面所有内容加载完毕(文档(html),css,js,img,video,字体图标)之后触发    => 放在所有内容的最后方
        window.onload = function(){
            var openBtn = document.getElementsByClassName("open")[0];
            var closeBtn = document.getElementsByClassName("close")[0];
            var scrollByBtn = document.getElementsByClassName("scrollBy")[0];
            var scrollToBtn = document.getElementsByClassName("scrollTo")[0];
            console.log(openBtn,closeBtn,scrollByBtn,scrollToBtn);
        }
    </script> -->
  <script src="../js/demo.js"></script>
</head>

<body>
  <button class="open">打开淘宝</button>
  <button class="close">关闭淘宝</button>
  <div class="fixed">
    <button class="scrollBy">scrollBy</button>
    <button class="scrollTo">scrollTo</button>
  </div>
</body>
<script>

  // window相关的事件(页面相关的事件)

  // 等页面所有内容加载完毕(文档(html),css,js,img,video,字体图标)之后触发
  // window.onload = function(){}

  // console.log(1);
  // // 页面加载时 并不会立即触发 =>而是等页面所有内容加载完毕(文档(html),css,js,img,video,字体图标)之后触发
  // window.onload = function(){
  //     console.log(2);
  // }
  // console.log(3);


  // onscroll   滚动条滚动时触发
  // window.onscroll = function(){
  //     console.log("scrollIng");
  // }

  // onresize  窗口大小发生改变时触发
  window.onresize = function () {
    console.log("窗口大小发生改变:", window.innerWidth, window.innerHeight);
  }
</script>

</html>